// mock/index.js
const token = require('./token.json');
const login = require('./login.json');
const role = require('./role.json');
const menu = require('./menu.json');
const paymentPlan = require('./paymentPlan.json');
const returnVisit = require('./returnVisit.json');
const logList = require('./logList.json');
//const bar = require('./bar');

module.exports = {
  // 同时支持 GET 和 POST
  //'/api/users/1': foo,
  //'/api/foo/bar': bar(),

  // '/api/login': (req, res) => {
  //   res.send({currentAuthority: '',success: true})
  // },
  '/api/login': token,

  // '/api/token': (req, res) => {
  //   res.send({
  //     content: new Date().getTime(),
  //     success: true,
  //   })
  // },

  '/api/token': login,

  '/api/role': role,

  '/api/menu': menu,

  '/api/paymentPlan': paymentPlan,

  '/api/returnVisit': returnVisit,

  '/api/logList': logList,

  // 支持标准 HTTP
  'GET /api/users': { users: [1, 2] },
  'DELETE /api/users': { users: [1, 2] },

  // 支持自定义函数，API 参考 express4
  'POST /api/users/create': (req, res) => {
    res.end('OK');
  },

  // 支持参数
  'POST /api/users/:id': (req, res) => {
    const { id } = req.params;
    res.send({ id: id });
  },
};